package com.crm.Servlet;

import com.crm.Service.CustomerService;
import com.crm.ServiceImpl.CustomerServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @version : 1.0
 * @auther : hjx
 * @Date : 2021/7/1
 * @Description : 实训
 */
public class updateCustomServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html; charset=UTF-8");
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");

        int custId = Integer.parseInt(req.getParameter("custId"));
        String custName= req.getParameter("custName");
        String custSource = req.getParameter("custSource");
        String custIndustry = req.getParameter("custIndustry");
        String custLevel = req.getParameter("custLevel");
        String custPhone = req.getParameter("custPhone");
        String custMobile = req.getParameter("custMobile");
        String custRegion = req.getParameter("custRegion");
        String custMemo = req.getParameter("custMemo");
        String custAddress = req.getParameter("custAddress");
        String custCorporation = req.getParameter("custCorporation");
        String custFax = req.getParameter("custFax");
        String custWebsite = req.getParameter("custWebsite");
        String custLicence = req.getParameter("custLicence");
        String custPic = req.getParameter("custPic");
        long custCapital = Integer.parseInt(req.getParameter("custCapital"));
        String custBank = req.getParameter("custBank");

        System.out.println("custId = " + custId);
        CustomerService customerService = new CustomerServiceImpl();
        customerService.updateCustomer(custId,custName, custSource,
                custIndustry, custLevel, custPhone,
                custMobile, custRegion, custCapital,
                custAddress, custMemo,custFax,
                custWebsite, custLicence, custPic,
                custCorporation, custBank);
        req.getRequestDispatcher("allCustomerServlet").forward(req,resp);
    }


}

